<?php
/**
 * 通知公告新增修改
 * User: hgq
 * Date: 2016/7/8 0008
 * Time: 下午 16:56
 */
use yii\helpers\Url;

$web = Url::base();

?>
<!-- 配置文件 -->
<script type="text/javascript" src="<?= $web ?>/components/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="<?= $web ?>/components/ueditor/ueditor.all.js"></script>
<script type="text/javascript" src="<?= $web ?>/components/ueditor/third-party/codemirror/codemirror.js"></script>
<script type="text/javascript" src="<?= $web ?>/components/ueditor/third-party/zeroclipboard/ZeroClipboard.js"></script>
<script type="text/javascript" src="<?= $web ?>/components/ueditor/lang/zh-cn/zh-cn.js"></script>
<link type="text/css" href="<?= $web ?>/components/ueditor/themes/default/css/ueditor.css" rel="stylesheet"/>
<link type="text/css" href="<?= $web ?>/components/ueditor/themes/iframe.css" rel="stylesheet"/>
<link type="text/css" href="<?= $web ?>/components/ueditor/third-party/codemirror/codemirror.css" rel="stylesheet"/>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    // 实例化编辑器
    var editor = UE.getEditor('edit_content_html');

    $(function ($) {
        var detail = <?=json_encode($detail)?>;
        editor.addListener("ready", function () {
            editor.setDisabled();
            if (detail != null) {
                var content_html = detail.content_html;
                editor.setContent(content_html);
            }
        });
    });
</script>
<div>
    <?php
    if ($detail != '') {
        ?>
        <form class="form-horizontal adminex-form">
            <div class="form-group">
                <input type="hidden" id="edit_id" class="form-control" value="<?= $detail["id"] ?>" readOnly="true">
                <input type="hidden" id="edit_institution_code" class="form-control"
                       value="<?= $detail["institution_code"] ?>" readOnly="true">

                <label class="col-sm-2 control-label">公告标题：</label>
                <div class="col-sm-4">
                    <input type="text" id="edit_title" class="form-control" style=" max-width: 260px " value="<?= $detail["title"] ?>">
                </div>
                <label class="col-sm-2 control-label">所属分类：</label>
                <div class="col-sm-4">
                    <select id="edit_category_id" class="form-control" style=" min-width: 200px; max-width: 260px " onchange="">
                        <?php
                        if ($category != null && $category != '') {
                            for ($i = 0; $i < count($category); $i++) {
                                ?>
                                <option
                                    value="<?= $category[$i]['id'] ?>" <?php if ($detail["category_id"] == $category[$i]['id']) echo "selected=\"selected\""; ?>><?= $category[$i]['name'] ?></option>
                                <?php
                            }
                        }
                        ?>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">公告描述：</label>
                <div class="col-sm-10">
                    <textarea id="edit_description" class="form-control" style="width: 716px;" rows="3"><?= $detail["description"] ?></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">是否显示：</label>
                <div class="col-sm-4">
                    <select id="edit_is_shown" class="form-control" style=" min-width: 200px; max-width: 260px " onchange="">
                        <option value="1" <?php if ($detail["is_shown"] == "1") echo "selected=\"selected\""; ?>>显示
                        </option>
                        <option value="0" <?php if ($detail["is_shown"] == "0") echo "selected=\"selected\""; ?>>不显示
                        </option>
                    </select>
                </div>
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-4">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">公告内容：</label>
                <div class="col-sm-9">
                    <div>
                        <!-- 加载编辑器的容器 -->
                        <script id="edit_content_html" name="content" type="text/plain" style="width:716px;height:400px;"></script>
                    </div>
                </div>
            </div>
        </form>
        <?php
    } else {
        ?>
        <form class="form-horizontal adminex-form">
            <div class="form-group">
                <input type="hidden" id="edit_id" class="form-control" value="" readOnly="true">
                <input type="hidden" id="edit_institution_code" class="form-control"
                       value="<?= $institution_code ?>" readOnly="true">

                <label class="col-sm-2 control-label">公告标题：</label>
                <div class="col-sm-4">
                    <input type="text" id="edit_title" class="form-control" style=" max-width: 260px " value="">
                </div>
                <label class="col-sm-2 control-label">所属分类：</label>
                <div class="col-sm-4">
                    <select id="edit_category_id" class="form-control" style=" min-width: 200px; max-width: 260px " onchange="">
                        <?php
                        if ($category != null && $category != '') {
                            for ($i = 0; $i < count($category); $i++) {
                                ?>
                                <option
                                    value="<?= $category[$i]['id'] ?>"><?= $category[$i]['name'] ?></option>
                                <?php
                            }
                        }
                        ?>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">公告描述：</label>
                <div class="col-sm-10">
                    <textarea id="edit_description" class="form-control" style="width: 716px;" rows="3"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">是否显示：</label>
                <div class="col-sm-4">
                    <select id="edit_is_shown" class="form-control" style=" min-width: 200px; max-width: 260px " onchange="">
                        <option value="1" selected="selected">显示</option>
                        <option value="0">不显示</option>
                    </select>
                </div>
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-4">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">公告内容：</label>
                <div class="col-sm-9">
                    <div>
                        <!-- 加载编辑器的容器 -->
                        <script id="edit_content_html" name="content" type="text/plain" style="width:716px;height:400px;"></script>
                    </div>
                </div>
            </div>
        </form>
        <?php
    }
    ?>
</div>